//
//  ViewController.m
//  testForBtn
//
//  Created by zhuo on 16/6/23.
//  Copyright © 2016年 zhuo. All rights reserved.
//

#import "ViewController.h"
#import "ZZButton.h"
#import "TTButton.h"

@interface ViewController ()

@property (nonatomic, strong) ZZButton * voiceButton;
@property (nonatomic, strong) UILabel * label;
@property (nonatomic, strong) UIButton * btn;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _label = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, 375, 50)];
    _label.tintColor = [UIColor cyanColor];
    [self.view addSubview:_label];
    [self loadVoiceButton];
//    [self loadMyButton];
//    [self loadButton];
    
    // add useless code.
    
}


- (void)loadButton{
    
   _btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 617, 375, 50)];
    _btn.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:_btn];
    
    [_btn setTitle:@"正常状态" forState:UIControlStateNormal];
    [_btn setTitle:@"按下按下按下" forState:UIControlStateHighlighted];
    [_btn addTarget:self action:@selector(begintouch) forControlEvents:UIControlEventTouchDown];
    [_btn addTarget:self action:@selector(endtouch) forControlEvents:UIControlEventTouchUpInside];
}

- (void)begintouch{
    
    _label.text = @"122313231231";
    
}

- (void)endtouch{
    
    _label.text = @"扎你皓道豆腐奶偶的那个覅按时到"
    ;
}

- (void)loadMyButton {
    
    TTButton * btn = [[TTButton alloc] initWithFrame:CGRectMake(0, 567, 375, 150)];
    btn.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:btn];
}

- (void)loadVoiceButton
{

    ZZButton *voiceButton = [[ZZButton alloc] initWithFrame:CGRectMake(50, 667-44, 325,44)];
    [self.view addSubview:voiceButton];
    
    [voiceButton setTitle:@"按住说话" forState:UIControlStateNormal];
    [voiceButton setTitle:@"松开结束" forState:UIControlStateHighlighted];
    
//    [voiceButton addTarget:self action:@selector(recordVoice) forControlEvents:UIControlEventTouchDown];
    [voiceButton addTarget:self action:@selector(sendVoice) forControlEvents:UIControlEventTouchUpInside];
    
    [voiceButton setBackgroundColor:[UIColor orangeColor]];
    [voiceButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [voiceButton setTitleColor:[UIColor yellowColor] forState:UIControlStateHighlighted];

    voiceButton.layer.masksToBounds = YES;
    voiceButton.layer.cornerRadius = 4;
    voiceButton.layer.borderColor = [[UIColor orangeColor] CGColor];
    voiceButton.layer.borderWidth = 0.5;

    _voiceButton = voiceButton;
}

-(void)recordVoice{
    
//    [self.voiceButton setHighlighted:YES];
    self.label.text = @"这是高亮高亮高亮高亮高亮状态";
}

-(void)sendVoice{
    
    [self.voiceButton setHighlighted:NO];
    self.label.text = @"normalnormalnormalnormalnormalnormal";
}

@end
